/**
 * Created by bestick on 2016/1/7.
 * faq页函数库
 */
$(document).ready(function() {

    //缓存jquery选择器
    var $a_navbar_link = $('a.navbar-link');
    var $navbar_product = $('#navbar_product');
    var $box_nav_li = $('.box-nav li');
    
    //隐藏导航
    $(window).click(function () {
        $('#navbar-collapse').removeClass('in');
    });

    //产品点击后更改图标上下拉
    $a_navbar_link.click(function () {
        if ($a_navbar_link.next('.dropdown-menu').css('display') == 'none') {
            $navbar_product.next().removeClass('glyphicon-chevron-down').addClass('glyphicon-chevron-up');
        } else {
            $navbar_product.next().removeClass('glyphicon-chevron-up').addClass('glyphicon-chevron-down');
        }
    });

    //产品失去焦点后
    $a_navbar_link.blur(function () {
        $navbar_product.next().removeClass('glyphicon-chevron-up').addClass('glyphicon-chevron-down');
    });

    $box_nav_li.click(function() {
        $(this).addClass('active').siblings().removeClass('active');
    });

    //nav-特点
    $box_nav_li.eq(0).click(function() {
        alert('TODO')
    });

    //nav-如何帮助
    $box_nav_li.eq(1).click(function() {
        $render('#how-we-help-temp', '#box-right', null);
    });

    //nav-我们是谁
    $box_nav_li.eq(2).click(function() {
        $render('#who-we-are-temp', '#box-right', null);

        //加载函数
        $(".person-frame a").each(function(){
            $(this).hover(
                function(){
                    $(this).find('.mask1').css({"top":"125px","left":"125px"});
                    $(this).find('.mask2').css({"top":"-160px","left":"-160px"});

                    $(this).find(".info_block").addClass("info_hover");
                },function(){
                    $(this).find(".mask1,.mask2").css({"top":0,"left":0});

                    $(this).find(".info_block").removeClass("info_hover");
                }
            );
        });
    });

    //nav-合作伙伴
    $box_nav_li.eq(3).click(function() {
        alert('TODO')
    });

    //nav-安全与隐私
    $box_nav_li.eq(4).click(function() {
        alert('TODO')
    });

    //nav-常见问题
    $box_nav_li.eq(5).click(function() {
        $render('#faq-temp', '#box-right', null, function() {
            $('.question-and-answer > .content-subTitle').click(function() {
                $(this).find('span').toggleClass('indicate-down');
                $(this).next().slideToggle('quick');
            })
        });
    });

    $box_nav_li.eq(1).click();

});

